function countBoxTr() {
    $("#boxCount").html($("tr[id^='box_TR']").length);
}
function setSelectValue(selectObje, valueHiddenId, textHiddenId, baseValueId, baseTextId) {
    var value = $("#" + baseValueId).val();
    var text = $("#" + baseTextId).val();
    setSelectValueByValueAndText(selectObje, value, text);
}

function setSelectValueByValueAndText(selectObje, value, text) {
    if (selectObje.attr("isInit") && selectObje.attr("isInit") == 1) {
        setSelectValueBase(selectObje, value, text);
    } else {
        var id = selectObje.attr("id") + "_show";
        $("#" + id).val(text);
        $(selectObje).val(value);
    }
    $("#" + selectObje.attr("valueid")).attr("value", value);
    $("#" + selectObje.attr("keyid")).attr("value", text);
}

function initHgDestinationCountry() {
    var DefaultValue = $("#hggoodsSelect_destinationCountry").attr("defaultValue");
    var DefaultText = $("#hggoodsSelect_destinationCountry").attr("defaultText");
    setSelectValueByValueAndText($("#hggoodsSelect_destinationCountry"), DefaultValue, DefaultText);

}

function setJySelectValue(selectObje, myValue, myText) {
    var id = selectObje.attr("id");
    id = id + "_show";

    if (selectObje.attr("isInit") && selectObje.attr("isInit") == 1) {
        setSelectValueBase(selectObje, myValue, myText);
    } else {
        $("#" + id).val(myText);
        $(selectObje).val(myValue);
    }

}

function setSelectValueBase(selectObje, value, text) {
    //  clearSelectValue(selectObje);
    initSelectTextAndValueWithoutClear(selectObje, text, value);
}

function caculatePriceBase(totalId, countId, priceId) {
    var total = $("#" + totalId).attr("value");
    var count = $("#" + countId).attr("value");
    if (total && count && count != '0') {
        $("#" + priceId).attr("value", (total / count).toFixed(4));
    }

}
function validateGoodsTable(tableId) {
    $("#" + tableId + " input").each(function (index, element) {
        var input = $(this);
        $("#myForm").validate().element(input);
    });
}

function validateBase(className) {
    var result = 1;
    $("." + className).each(function () {
        var value = $(this).val();
        $(this).parent().prev().css("background-color", "");

        if (value == "") {
            result = 0;
            $(this).parent().prev().css("background-color", "#fedbc4");
        }
    });
    return result;
}

function clearInputBeforeTr(contentId, isClearSelect) {
    $("#" + contentId + " input[type!='button'][notClear!='notClear']").each(
        function (index, element) {
            if ($(element).attr("selectData")) {
                try {
                    $(element).combogrid("clear");
                } catch (e) {

                }
            } else {
                $(element).val("");
            }
        });
    if (isClearSelect) {
        $("#" + contentId + " select").each(function (index, element) {
            //$(element).get(0).options[0].selected = true;
            var elementJq = $(element);
            elementJq.combobox("clear");
            elementJq.combobox("select", elementJq.get(0).options[0].value);

        });
    }

}

function initSerIdIndexValue(goodSerId, appSerId, subSerId, boxSerId) {
    hwxxjlSerIdIndex = subSerId;
    setHwxxjlSerId(subSerId);
    xkzSerIdIndex = appSerId;
    setXkzSerId(appSerId);
    goodSerIdIndex = goodSerId;
    setGoodSerId(goodSerId);
    boxSerIdIndex = boxSerId;
    setBoxSerId(boxSerId);
}

//---------------小写转大写
function changeUpper(value) {
    $(value).val($(value).val().toLocaleUpperCase());
}

/************关检复制***************/
function copyGjNewOne() {

    copyJyjyNewOne();
    copyHgNewOne();
    unlock();

}

function dealWithExcelImportData(jsonData) {
    var goodList = jsonData.InspectAndDeclareGoods;
    var good;
    var trHtml = "";
    for (var index = 0; index < goodList.length; index++) {
        good = goodList[index];
        trHtml += excelImportSetTr(goodSerIdIndex, good);
        goodSerIdIndex++;
    }
    $("#good_lastTR").before(trHtml);
    if (good_edit_serid == null || good_edit_serid == "") {
        setGoodSerId(goodSerIdIndex);
    }
    reSetShowSerid();
    noticesHgGoodCounts();
}

function escapeStr(value) {
    return value.replace(/["]/g, '&#34;');
}

function replaceZero(value) {
    if (value == 0 || value == "0") {
        return "";
    }
    return value;
}

function excelImportSetTr(goodSerId, good) {
    var trHtml = "<tr id=\"good_TR" + goodSerId + "\" onclick=\"editGoodTr(" + goodSerId + ");\">";

    trHtml += "<td>" +
              "<input  id=\"goodshow_serid_" + goodSerId
              + "\" type=\"text\" value=\"\"  readonly=\"readonly\" \>" +
              "<input type=\"hidden\" id=\"good_serid_" + goodSerId
              + "\" size=\"10\" readonly=\"readonly\" value=\"" + goodSerId + "\"></td>";
    trHtml +=
        "<td><input type=\"text\" id=\"hggoods_spbhdm_" + goodSerId
        + "\"  readonly=\"readonly\" value=\"" + good.baHggoods.spbhdm + "\"></td>";
    trHtml +=
        "<td><input type=\"text\"  name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.spmc\" id=\"hggoods_spmc_" + goodSerId
        + "\"  readonly=\"readonly\"  value =\"" + escapeStr(good.baHggoods.spmc) + "\"></td>";
    trHtml +=
        "<td><input id=\"hggoods_sbsl_" + goodSerId
        + "\" type=\"text\"  readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.sbsl\" value=\"" + good.baHggoods.sbsl + "\"></td>";
    trHtml +=
        "<td><input type=\"text\" id=\"hggoods_sbjldwName_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.sbjldwName\" value=\"" + good.baHggoods.sbjldwName
        + "\" readonly=\"readonly\" /></td>";
    trHtml +=
        "<td><input type=\"text\"  name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.zj\" id=\"hggoods_zj_" + goodSerId + "\"  readonly=\"readonly\"  value=\""
        + good.baHggoods.zj + "\"></td>";
    trHtml +=
        "<td><input type=\"text\"   id=\"hggoods_bzName_" + goodSerId
        + "\"  readonly=\"readonly\"  value=\"" + good.baHggoods.bzName + "\"></td>";
    trHtml += "<td style=\"text-align:center;\" >";
    //<!-- 国检特有字段 第一行 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.dm\" id=\"good_ciqdm_" + goodSerId
        + "\" size=\"10\"  type=\"hidden\" readonly=\"readonly\" value=\"" + good.jyjygoods.dm
        + "\">";
    trHtml +=
        "<input  id=\"good_ciqdmCode_" + goodSerId + "\" name=\"\" value=\"" + good.jyjygoods.dmName
        + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input  id=\"good_lm_" + goodSerId + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].jyjygoods.lm\" value=\"" + good.jyjygoods.lm
        + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input  id=\"good_jyjylb_" + goodSerId + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].jyjygoods.jyjylb\" value=\"" + good.jyjygoods.jyjylb
        + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input  id=\"good_hgjgtj_" + goodSerId + "\" name=\"jyjy.goods[" + goodSerId
        + "].hgjgtj\" value=\"" + good.jyjygoods.hgjgtj
        + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.hwywmc\" id=\"good_ywmc_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\" type=\"hidden\" value=\"" + escapeStr(
            good.jyjygoods.hwywmc) + "\">";
    trHtml +=
        "<input id=\"good_hwlx_" + goodSerId + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].jyjygoods.goodSort\" value=\"" + good.jyjygoods.goodSort
        + "\" type=\"hidden\" readonly=\"readonly\">";
    //<!-- 国检特有字段 第二行 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.sl\" id=\"good_bjsl_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.sl) + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.sldwdm\" id=\"good_sldw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.sldwdm
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_sldwmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.sldwName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.zl\" id=\"good_bjzl_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.zl) + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.zldwdm\" id=\"good_zldw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.zldwdm
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_zldwmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.zldwdmName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.fjwpbs\" id=\"good_fjbs_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.fjwpbs
        + "\">";
    //<!-- 国检特有字段 第三行 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.bzsl\" id=\"good_bzsl_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bzsl
        + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.bzlxdm\" id=\"good_bzzl_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bzlxdm
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_bzzlmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.bzlxdmName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.yztjbs\" id=\"good_yztj_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.yztjbs
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_yztjmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.yztjbsName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.ycgdm\" id=\"good_ycd_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.ycgdm
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_ycdmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.ycgName + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.ytdm\" id=\"good_yt_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.ytdm
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_ytmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.ytdmName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    //<!-- 国检特有字段 第四行 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.fzbz\" id=\"good_fzbzdm_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.fzbz
        + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_fzbzmc_" + goodSerId + "\" name=\"\" value=\""
        + good.jyjygoods.fzbzName + "\" type=\"hidden\" readonly=\"readonly\"/>";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.bzjs\" id=\"good_bzjs_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.bzjs) + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.c\" id=\"good_c_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.c) + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.k\" id=\"good_k_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.k) + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.g\" id=\"good_g_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + replaceZero(
            good.jyjygoods.g) + "\">";
    //<!-- 国检特有字段 第五行 -->
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_clzl_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.clzl\" value=\"" + good.jyjygoods.clzl
        + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.jgcj\" id=\"good_jgcj_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.jgcj
        + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.sfctsb\" id=\"good_sfctsb_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.sfctsb
        + "\">";
    //<!-- 国检特有字段 第六行 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.qzbj\" id=\"good_qzciq_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.qzbj
        + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.dydzwjqcpyjw\" id=\"good_dydzwjqcpyjw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\""
        + good.jyjygoods.dydzwjqcpyjw + "\">";
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_dangerFlag_" + goodSerId + "\" name=\"jyjy.goods["
        + goodSerId + "].dangerFlag\" value=\"" + good.jyjygoods.dangerFlag
        + "\" type=\"hidden\" readonly=\"readonly\">";
    //<!-- 公共 -->
    trHtml +=
        "<input style=\"\" size=\"10\" id=\"good_hsbh_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId + "].jyjygoods.bm\" value=\""
        + good.jyjygoods.bm + "\" type=\"hidden\" readonly=\"readonly\">";
    trHtml +=
        "<input type=\"hidden\" id=\"good_hsbhmc_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bmName + "\">";
    trHtml +=
        "<input type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.hwzwmc\" id=\"good_zwmc_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.hwzwmc + "\" >";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.hwgg\" class=\"valid\" id=\"good_ggxh_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + escapeStr(
            good.jyjygoods.hwgg) + "\">";
    trHtml +=
        "<input type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.bzl\" id=\"good_bzl_" + goodSerId
        + "\"  size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bzl + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.bzldw\" id=\"good_bzldw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bzldw
        + "\">";
    trHtml +=
        "<input type=\"hidden\" name=\"\" id=\"good_bzldwmc_" + goodSerId
        + "\"  size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.bzldwName + "\">";
    trHtml +=
        "<input type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.je\" id=\"good_hwzz_" + goodSerId
        + "\"  size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.je + "\">";
    trHtml +=
        "<input id=\"good_hwdj_" + goodSerId
        + "\" type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.dj\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.dj + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.hbdw\" id=\"good_bz_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.hbdw
        + "\">";
    trHtml +=
        "<input id=\"good_bzmc_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.hbdwName
        + "\">";
    //<!-- 出口 -->
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.hwzph\" id=\"good_zph_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.hwzph
        + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.scdwzch\" id=\"good_scdwzch_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.scdwzch
        + "\">";
    trHtml +=
        "<input name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].jyjygoods.sccjmc\" id=\"good_sccjmc_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" value=\"" + good.jyjygoods.sccjmc
        + "\">";
    //<!--  海关特有字段 第一行 -->
    trHtml +=
        "<input id=\"hggoods_sbjldw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.sbjldw\" value=\"" + good.baHggoods.sbjldw + "\">";
    trHtml +=
        "<input id=\"hggoods_desl_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.desl\" value=\"" + replaceZero(good.baHggoods.desl) + "\">";
    trHtml +=
        "<input id=\"hggoods_dejldw_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.dejldw\" value=\"" + good.baHggoods.dejldw + "\">";
    trHtml +=
        "<input type=\"hidden\" id=\"hggoods_dejldwName_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.dejldwName\" value=\"" + good.baHggoods.dejldwName
        + "\" readonly=\"readonly\" style=\"width: 100%\"/>";
    trHtml +=
        "<input id=\"hggoods_htspxmxh_" + goodSerId
        + "\" size=\"10\" type=\"hidden\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.htspxmxh\" value=\"\">";  //good.baHggoods.htspxmxh
    //<!--  海关特有字段 第二行 -->
    trHtml +=
        "<input id=\"hggoods_bbh_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.bbh\" value=\"" + good.baHggoods.bbh + "\">";
    trHtml +=
        "<input id=\"hggoods_hh_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.hh\" value=\"" + good.baHggoods.hh + "\">";
    trHtml +=
        "<input id=\"hggoods_yt_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.yt\" value=\"" + good.baHggoods.yt + "\">";
    trHtml +=
        "<input type=\"hidden\" id=\"hggoods_ytName_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.ytName\" value=\"" + good.baHggoods.ytName
        + "\" readonly=\"readonly\" style=\"width: 100%\"/>";
    trHtml +=
        "<input id=\"hggoods_ycgmdg_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.ycgmdg\" value=\"" + good.baHggoods.ycgmdg + "\">";
    trHtml +=
        "<input type=\"hidden\" id=\"hggoods_ycgmdgName_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.ycgmdgName\" value=\"" + good.baHggoods.ycgmdgName
        + "\" readonly=\"readonly\" style=\"width: 100%\"/>";
    trHtml +=
        "<input id=\"hggoods_zm_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.zm\" value=\"" + good.baHggoods.zm + "\">";
    trHtml +=
        "<input type=\"hidden\" id=\"hggoods_zmName_" + goodSerId
        + "\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.zmName\" value=\"" + good.baHggoods.zmName
        + "\" readonly=\"readonly\" style=\"width: 100%\"/>";

    trHtml +=
        "<input id=\"hggoods_destinationCountry_" + goodSerId
        + "\" type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.destinationCountry\" value=\"" + good.baHggoods.destinationCountry + "\" \>";
    trHtml +=
        "<input id=\"hggoods_destinationCountryName_" + goodSerId + "\" type=\"hidden\"  value=\""
        + good.baHggoods.destinationCountryName + "\" \>";
    //<!-- 公共字段 -->
    trHtml +=
        "<input type=\"hidden\"  id=\"hggoods_spbh_" + goodSerId
        + "\" size=\"10\"  readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.spbh\" value=\"" + good.baHggoods.spbh + "\"  />";
    trHtml +=
        "<input id=\"hggoods_spggxh_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\" type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.spggxh\" value=\"" + escapeStr(good.baHggoods.spggxh) + "\">";
    trHtml +=
        "<input type=\"hidden\"  id=\"hggoods_dyjldw_" + goodSerId
        + "\" size=\"10\"  readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.dyjldw\" value=\"" + good.baHggoods.dyjldw + "\"  />";
    trHtml +=
        "<input id=\"hggoods_dj_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\" type=\"hidden\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.dj\" value=\"" + good.baHggoods.dj + "\">";
    trHtml +=
        "<input id=\"hggoods_bz_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\"  name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.bz\" value=\"" + good.baHggoods.bz + "\">";
    trHtml +=
        "<input  type=\"hidden\"  id=\"hggoods_dyjldwName_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\"  value=\"" + good.baHggoods.dyjldwName + "\">";
    trHtml +=
        "<input  type=\"hidden\"  name=\"baHgbaseinfo.inspectAndDeclareGoods[" + goodSerId
        + "].baHggoods.dysl\" id=\"hggoods_dysl_" + goodSerId
        + "\" size=\"10\" readonly=\"readonly\"  value=\"" + good.baHggoods.dysl + "\">";
    //<!-- 出口 -->
    trHtml +=
        "<input id=\"hggoods_gjf_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.gjf\" value=\"" + replaceZero(good.baHggoods.gjf) + "\">";
    trHtml +=
        "<input id=\"hggoods_sccj_" + goodSerId
        + "\" type=\"hidden\" size=\"10\" readonly=\"readonly\" name=\"baHgbaseinfo.inspectAndDeclareGoods["
        + goodSerId + "].baHggoods.sccj\" value=\"" + good.baHggoods.sccj + "\">";
    trHtml += "</td>";
    trHtml += "<td style=\"text-align:center;\">";
    trHtml += "<img src=\"../image/delete.gif\" onclick=\"deleteJyGoodTr(" + goodSerId + ")\">";
    trHtml += "<table id=\"good_xkzs_div_" + goodSerId + "\" style=\"display: none;\">";
    trHtml += "<tbody>";
    trHtml += "</tbody>";
    trHtml += "</table>";
    trHtml += "<table id=\"good_hwxxjls_div_" + goodSerId + "\" style=\"display: none;\">";
    trHtml += "<tbody>";
    trHtml += "</tbody>";
    trHtml += "</table>";
    trHtml += "</td>";

    trHtml += "</tr>";
    return trHtml;
}

var ajaxFileUpload_eoflag; // 0  进口, 1 出口
function setAjaxFileUpload_eoflag(value) {
    ajaxFileUpload_eoflag = value;
}
function ajaxFileUpload() {
    var jylock = $("#JYISLOCK").val();
    var hglock = $("#HGISLOCK").val();
    if (jylock == "1" || hglock == "1") {
        $.messager.alert('提示', "该数据正在申报,不可添加商品.");
        return;
    }

    var fileId = 'file1';
    if (!$("#" + fileId).val()) {
        $.messager.alert('提示', "请选择文件.");
        return;
    }
    $("html").mask("正在处理数据...");
    $.ajaxFileUpload
    (
        {
            url: 'report_importGood.do', //用于文件上传的服务器端请求地址
            type: 'post',
            data: {"eoFlag": ajaxFileUpload_eoflag}, //此参数非常严谨，写错一个引号都不行
            secureuri: false, //一般设置为false
            fileElementId: fileId, //文件上传空间的id属性  <input type="file" id="file" name="file" />
            dataType: 'text', //返回值类型 一般设置为json
            success: function (data, status)  //服务器成功响应处理函数
            {

                $("input[type=file]").each(function () {
                    if ($(this).val() == "") {
                        $(this).parents(".uploader").find(".filename").val("没有选择文件...");
                    }
                });
                $("html").unmask();
                var jsonData;
                try {
                    jsonData = eval("(" + data + ")");
                } catch (e) {
                    showErrorShowDiv("返回数据错误", data);
                    return;
                }
                data = null;
                if (jsonData && jsonData.errorDetail && jsonData.errorDetail != '') {
                    var errorTitle = "";
                    try {
                        errorTitle = jsonData.error;
                    } catch (e) {
                        errorTitle = "";
                    }
                    showErrorShowDiv(errorTitle, jsonData.errorDetail);
                    return;
                }
                dealWithExcelImportData(jsonData);

            },
            error: function (data, status, e)//服务器响应失败处理函数
            {
                $("html").unmask();
                $.messager.alert('提示', "网络异常，请稍后再试！");

            }
        }
    )

}

function checkBeforSave() {
    var sbkaValu = $("#sbkaHidden").attr("value");
    var message = "";
    var inputAreaMessageDefaul = "";
    var inputAreaMessage = inputAreaMessageDefaul;
    var tmpValue;
    if (sbkaValu) {

    } else {
        message += "申报口岸(申报地海关)未填写。<br>";
    }

    tmpValue = $("#good_hsbh").attr("value");
    if ((good_edit_serid != null && good_edit_serid != "") || (tmpValue != null && tmpValue
                                                                                   != "")) {
        inputAreaMessage += "<span style='color:red;'>商品</span>";
    } else {
        tmpValue = $("#hggoods_spbh").attr("value");
        if ((hggoods_edit_serid != null && hggoods_edit_serid != "") || (tmpValue != null
                                                                         && tmpValue != "")) {
            inputAreaMessage += "<span style='color:red;'>商品</span>";
        }
    }
    tmpValue = $("#box_jzxgg").attr("value");
    var jzxh = $("#box_jzxh").attr("value");
    if ((box_edit_serid != null && box_edit_serid != "") || ((tmpValue != null && tmpValue != "")
                                                             && (jzxh != null && jzxh != ""))) {
        if (inputAreaMessage != inputAreaMessageDefaul) {
            inputAreaMessage += "、";
        }
        inputAreaMessage += "<span style='color:red;'>集装箱</span>";
    }

    try {
        tmpValue = $("#atta_dzdm").attr("value");
        var dzbm = $("#atta_dzbm").attr("value");

        if ((atta_edit_serid != null && atta_edit_serid != "") || ((tmpValue != null && tmpValue
                                                                                        != "")
                                                                   && (dzbm != null && dzbm
                                                                                       != ""))) {
            if (inputAreaMessage != inputAreaMessageDefaul) {
                inputAreaMessage += "、";
            }
            inputAreaMessage += "<span style='color:red;'>海关随附单据</span>";
        }
    } catch (e) {

    }
    if (inputAreaMessage != inputAreaMessageDefaul) {
        //inputAreaMessage="请先点击"+inputAreaMessage+"的“添加”或“修改”按钮,再进行本次操作。";
        inputAreaMessage = "您正在编辑" + inputAreaMessage + "信息，请先点击“添加”或“修改”按钮进行保存";
        message += inputAreaMessage;
    }

    if (message != "") {
        $.messager.alert('提示', message);
        return false;
    }

    /*if(message !=""){
     var r = confirm( message+",是否忽略?");
     if (r) {
     return false;
     }

     }*/
    return true;

}

function hasValue(areaId, tag) {
    var result = 0;
    $("#" + areaId + " *[" + tag + "]").each(function () {
        var value = $(this).attr("value");
        if (value && value != "") {
            alert(this.id);
            result++;
        }
    });
    return result;
}

function reSetShowSerid() {
    var index = 1;
    $("input[id*='goodshow_serid_']").each(function () {
        $(this).attr("value", index);
        index++;
    });
    $("#goodshow_serid").attr("value", index);
}

var ajaxFileUpload_BoxType; // 0  检验检疫, 1 海关/关检
function setAjaxFileUpload_BoxType(value) {
    ajaxFileUpload_BoxType = value;
}

function ajaxFileUploadForBox() {
    var jylock = $("#JYISLOCK").val();
    var hglock = $("#HGISLOCK").val();
    if (jylock == "1" || hglock == "1") {
        $.messager.alert('提示', "该数据正在申报,不可添加集装箱.");
        return;
    }

    var fileId = 'fileForBox';
    if (!$("#" + fileId).val()) {
        $.messager.alert('提示', "请选择文件.");
        return;
    }
    $("html").mask("正在处理数据...");
    $.ajaxFileUpload
    (
        {
            url: 'report_importBox.do', //用于文件上传的服务器端请求地址
            type: 'post',
            data: {"importType": ajaxFileUpload_BoxType}, //此参数非常严谨，写错一个引号都不行
            secureuri: false, //一般设置为false
            fileElementId: fileId, //文件上传空间的id属性  <input type="file" id="file" name="file" />
            dataType: 'text', //返回值类型 一般设置为json
            success: function (data, status)  //服务器成功响应处理函数
            {
                $("html").unmask();
                //alert(data);
                $("#" + fileId).val("");
                $("#" + fileId).parents(".uploader").find(".filename").val("没有选择文件...");

                var jsonData;
                try {
                    jsonData = eval("(" + data + ")");
                } catch (e) {
                    showErrorShowDiv("返回数据错误", data);
                    return;
                }
                if (jsonData && jsonData.errorDetail && jsonData.errorDetail != '') {
                    var errorTitle = "";
                    try {
                        errorTitle = jsonData.error;
                    } catch (e) {
                        errorTitle = "";
                    }
                    showErrorShowDiv(errorTitle, jsonData.errorDetail);
                    return;
                }
                dealWithExcelImportBoxData(jsonData);

            },
            error: function (data, status, e)//服务器响应失败处理函数
            {
                //alert(e.message);
                $("html").unmask();
                $.messager.alert('提示', "网络异常，请稍后再试！");
            }
        }
    )

}

function dealWithExcelImportBoxData(jsonData) {
    if (ajaxFileUpload_BoxType == "0") {
        dealWithExcelImportJyBoxData(jsonData);
    } else if (ajaxFileUpload_BoxType == "1") {
        dealWithExcelImportHgBoxData(jsonData);
    }
}

function dealWithExcelImportHgBoxData(jsonData) {
    var boxList = jsonData.boxs;
    var box;
    var trHtml = "";
    var exception = "";
    var exitElement;
    for (var index = 0; index < boxList.length; index++) {
        box = boxList[index];
        exitElement = $("input[id*='box_jzxh_'][value='" + box.jzxh + "']");
        if (exitElement && exitElement.attr("id")) {
            exception += "集装箱号(" + box.jzxh + ")已添加,请勿重复添加.<br>";
        } else {
            trHtml += excelImportForHgBoxSetTr(box);
        }
        boxSerIdIndex++;
    }
    if (exception != "") {
        showErrorShowDiv(exception, exception);
        boxSerIdIndex -= boxList.length;
    } else {
        setBoxSerIdIndex(boxSerIdIndex);
        $("#box_lastTR").before(trHtml);
        countBoxTr();
    }
}

function dealWithExcelImportJyBoxData(jsonData) {
    var boxList = jsonData.boxs;
    var box;
    var trHtml;
    var exception = "";
    var exitElement;
    for (var index = 0; index < boxList.length; index++) {
        box = boxList[index];
        exitElement = $("input[id*='box_jzxh_'][value='" + box.jzxh + "']");
        if (exitElement && exitElement.attr("id")) {
            exception += "集装箱号(" + box.jzxh + ")已添加,请勿重复添加.<br>";
        } else {
            if (exception == "") {
                trHtml += excelImportForJyBoxSetTr(box);
            }
        }
        boxSerIdIndex++;
    }
    if (exception == "") {
        $("#box_lastTR").before(trHtml);
        reSetBoxShowSerid();
        setBoxSerId(boxSerIdIndex);
        if (box_edit_serid != "") {
            $("#boxshow_serid").attr("value", $("#boxshow_serid_" + box_edit_serid).attr("value"));
        }
        countBoxTr();
    } else {
        boxSerIdIndex -= boxList.length;
        showErrorShowDiv(exception, exception);
    }
}

function excelImportForHgBoxSetTr(box) {
    var jzxzz = box.jzxzz;
    if (jzxzz == 0) {
        jzxzz = "";
    }
    var html = getNewHgBoxHtml(box.jzxh, box.jzxgg, box.jzxggName, jzxzz);
    return html;
}

function getJyBoxHtmlByField(box_serid, jzxgg, id, jzxslbj, jzxggCode, jzxggName, jzxh) {
    var html = '<tr id="box_TR' + box_serid + '" onclick="editBoxTr(' + box_serid
               + ')" style="text-align:center;">'
               + '<input style="" size="10" id="box_serid_' + box_serid + '" name="" value="'
               + box_serid + '" type="hidden" readonly="readonly">'
               + '<input style="" size="10" id="box_jzxgg_' + box_serid + '" name="jyjy.boxs['
               + box_serid + '].jzxgg" value="' + jzxgg + '" type="hidden" readonly="readonly">'
               + '<input style="" size="10" id="box_id_' + box_serid + '" name="jyjy.boxs['
               + box_serid + '].id" value="' + id + '" type="hidden" readonly="readonly">'
               + '<input style="" size="10" id="box_jzxslbj_' + box_serid + '" name="jyjy.boxs['
               + box_serid + '].jzxslbj" value="' + jzxslbj + '" type="hidden" readonly="readonly">'
               + '<td><input style="" size="10" id="boxshow_serid_' + box_serid
               + '" name="" value="" readonly="readonly" class="valid"></td>'
               + '<td><input style="" size="10" id="box_jzxggCode_' + box_serid
               + '" name="" value="' + jzxggCode + '" readonly="readonly"></td>'
               + '<td><input style="" size="10" id="box_jzxggName_' + box_serid
               + '" name="" value="' + jzxggName + '" readonly="readonly"></td>'
               + '<td><input style="" size="10" id="box_jzxh_' + box_serid + '" name="jyjy.boxs['
               + box_serid + '].jzxh" value="' + jzxh + '" readonly="readonly"></td>'
               + '<td style="text-align:center;"><img src="../image/delete.gif" onclick="deleteJybox('
               + box_serid + ')"></td>'
               + '</tr>';
    return html;
}

function excelImportForJyBoxSetTr(box) {
    return getJyBoxHtmlByField(boxSerIdIndex, box.jzxgg, '', '1', box.jzxggCode, box.jzxggName,
                               box.jzxh);
}

function checkTabDiv(tabTitileName, validRangeId) {

    /*var result = true;
     var validResult = true;
     var elementRule = "#"+validRangeId+" input[name][class*='{']";
     if("good_show_tble" == validRangeId){
     elementRule +="[value='']";
     }
     var element = $(elementRule);
     var length = element.length;
     var formValidator = $("#myForm").validate();
     for(var index = 0 ; index < length ; index ++){
     try{
     result = formValidator.element(element[index]);
     if(validResult == true && result == false){
     validResult = false;
     }
     }catch(e){

     }
     }
     if(validResult == false){
     $("span[class='tabs-title']:contains('"+tabTitileName+"')").html(""+tabTitileName+"<span class=\"tabstar\">●</span>");
     $.messager.alert('提示',tabTitileName+"存在数据项校验不通过.");
     }*/
    var result = "";
    var elementRule = "#" + validRangeId + " label[class='error'][generated='true']";
    var element = $(elementRule);
    if (element.length > 0) {
        $("span[class='tabs-title']:contains('" + tabTitileName + "')").html(
            "" + tabTitileName + "<span class=\"tabstar\">●</span>");
        result = tabTitileName + "存在数据项校验不通过.";
    } else {
        try {
            $("span[class='tabs-title']:contains('" + tabTitileName
              + "') span[class='tabstar']").remove();
        } catch (e) {

        }
    }
    return result;
}

function checkMainForm() {
    return checkTabDiv("单证信息", "mainFormTable");
}
function checkGoodForm() {
    return checkTabDiv("货物信息", "good_show_tble");
}

function checkGJLHTab() {
    var result = checkMainForm();
    if (result != "") {
        result += "<br>";
    }
    result += checkGoodForm();
    if (result != "") {
        $.messager.alert('提示', result);
    }
}

var tr;
var turl;
var tformId;
var tOtherFormParam;
var tCallBackFunctionName;
var tJsonData;
function ajaxSubmitBase(url, formId, otherFormParam, callBackFunctionName) {
    /* $("body").mask("数据正在传输处理,请稍等!"); */
    if (!checkBeforSave()) {
        return;
    }
    $.messager.progress({
                            title: '请等待',
                            msg: '正在提交',
                            text: '处理中......'
                        });
    $.messager.confirm('提示', '确定提交?', function (r) {
        tr = r;
        turl = url;
        tformId = formId;
        tOtherFormParam = otherFormParam;
        tCallBackFunctionName = callBackFunctionName;
        setTimeout("ajaxsubmitDetail( tr,turl,tformId,tOtherFormParam,tCallBackFunctionName)", 10);
    });
}

function ajaxsubmitDetail(r, url, formId, otherFormParam, callBackFunctionName) {
    if (r) {
        $.ajax({
                   cache: true,
                   type: "POST",
                   url: url,
                   data: otherFormParam + $('#' + formId).serialize(),// 你的formid
                   async: false,
                   contentType: "application/x-www-form-urlencoded; charset=utf-8",
                   error: function (request) {
                       $.messager.progress('close');

                       $.messager.alert('提示', "网络异常，请稍后再试！");
                   },
                   success: function (data) {
                       $.messager.progress('close');
                       if (!data.result) {
                           showErrorShowDiv(data.msg, data.msg);
                           return;
                       }
                       try {
                           var jsonData = data.data;
                           if (callBackFunctionName && callBackFunctionName != "") {
                               eval(callBackFunctionName + "(jsonData)");
                           }
                       } catch (e) {
                       }
                       /**var jsonData;
                        try{
				        	  	 jsonData =eval("("+data+")");
				        	   }catch(e){
				        		   showErrorShowDiv("返回数据错误",data);
				        		   $.messager.progress('close');
				        		   return;
				        	   }
                        if(jsonData && jsonData.errorDetail && jsonData.errorDetail !='' ){
				        	   		var errorTitle = "";
				        	   		try{
				        	   			errorTitle = jsonData.error;
				        	   		}catch(e){
				        	   		    errorTitle = "";
				        	   		}
				        		   showErrorShowDiv(errorTitle,jsonData.errorDetail);
				        	   }else if(jsonData && jsonData.lockMessage && jsonData.lockMessage !=''){
				        		   $.messager.alert('提示',jsonData.lockMessage);
				        	   }else if(jsonData && jsonData.versionError && jsonData.versionError !=''){
				        		   $.messager.alert('提示',jsonData.versionError);
				        	   }else{
					        	   try{
					        		   if(callBackFunctionName && callBackFunctionName !=""){
					        			   rJsonData = jsonData;
					        			   eval(callBackFunctionName+"(jsonData)");
					        		   }
					        	   }catch(e){
					        	   }
				        	   }
                        $.messager.progress('close');
                        **/
                   }
               });
    } else {
        $.messager.progress('close');
        return;
    }
}

function entryHgAjaxCallBack(jsonData) {
    hgAjaxCallBack(jsonData, "entryDeclare_update.do");
}

function exportHgAjaxCallBack(jsonData) {
    hgAjaxCallBack(jsonData, "exportDeclare_update.do");
}

function entryHgAndJyAjaxCallBack(jsonData) {
    hgAndJyAjaxCallBack(jsonData, "entryDeclareAndInspect_update.do");
}

function exportHgAndJyAjaxCallBack(jsonData) {
    hgAndJyAjaxCallBack(jsonData, "exportDeclareAndInspect_update.do");
}

function ajyAjaxCallBack(jsonData) {
    jyAjaxCallBack(jsonData);
}

function hgAjaxCallBack(jsonData, updateUrl) {
    setHgReturnValue(jsonData.baHgbaseinfo);
    setHgReturnGoodListValue(jsonData.goodlist);
    setHgReturnBoxListValue(jsonData.boxlist);
    resetIframe(jsonData.baHgbaseinfo.gjh);
    initFileds(); //把表单值保存，用来检查表单值是否有改动
    var messageStr = "保存成功" + hgZhuJianShenbao(jsonData, updateUrl);
    $.messager.alert('提示', messageStr);
}

function jyAjaxCallBack(jsonData) {
    setJyjyReturnValue(jsonData.jyjy);
    setJyjyReturnGoodListValue(jsonData.goodlist);
    setJyjyReturnBoxListValue(jsonData.boxlist);
    resetIframe(jsonData.jyjy.gjh);
    /*  console.log(jsonData.retJson);
     console.log(jsonData.retJson.resUrl); */
    if (jsonData.retJson && jsonData.retJson != "") {
        // 	window.open(jsonData.retJson.resUrl);
        if (jsonData.retJson.resUrl) {
            openJyBaoWenDiv(jsonData.retJson.resUrl);
        } else {
            $.messager.alert('提示', "已申报，确认回执链接错误,请联系管理员！");
        }
    } else {
        $.messager.alert('提示', "操作成功");
    }

    initFileds(); //把表单值保存，用来检查表单值是否有改动
}

function hgAndJyAjaxCallBack(jsonData, hgUpdateUrl) {
    setHgReturnValue(jsonData.baHgbaseinfo);
    setJyjyReturnValue(jsonData.jyjy);
    resetIframe(jsonData.baHgbaseinfo.gjh);
    if (jsonData.retJson && jsonData.retJson != "") {
        if (jsonData.retJson.resUrl) {
            openJyBaoWenDiv(jsonData.retJson.resUrl);
        } else {
            //	alert("已申报，确认回执链接错误,请联系管理员！");
            $.messager.alert('提示', "已申报，确认回执链接错误,请联系管理员！");
        }
    }
    var jylock = $("#JYISLOCK").val();
    var hglock = $("#HGISLOCK").val();
    if (jylock == "1" || hglock == "1") {
        lock();
    }
    initFileds(); //把表单值保存，用来检查表单值是否有改动
    var messageStr = "保存成功" + hgZhuJianShenbao(jsonData, hgUpdateUrl);
    $.messager.alert('提示', messageStr);
}

function hgZhuJianShenbao(jsonData, updateUrl) {
    var messageStr = "";
    try {
        var bill = JSON.stringify(jsonData.hgjsonstr);

        if (bill && bill != '' && bill != 'null') {
            bill = unescape(bill.replace(/\\u/g, "%u"));
            var excuteResult = HgZhuJianShenBaoExecute(bill);
            if (excuteResult && excuteResult != '') {
                showErrorShowDiv(messageStr + ",提交申报失败", excuteResult);
            } else {
                messageStr += ",提交申报成功。";
                var gjh = $("#GJH").attr("value");
                var gjglmm = $("#GJGLMM").attr("value");
                var url = updateUrl + "?baHgbaseinfo.gjh=" + gjh + "&baHgbaseinfo.gjglmm=" + gjglmm
                          + "&type=0";
                ajax4Biz(null, url, updateAfterDeclare, null, true, "get");
            }
        }
    } catch (billEx) {

    }
    return messageStr;
}

function updateAfterDeclare(data) {
    var jsonData;
    try {
        jsonData = eval("(" + data + ")");
    } catch (e) {
        showErrorShowDiv("返回数据错误", data);
        return;
    }
    if (jsonData && jsonData.errorDetail && jsonData.errorDetail != '') {
        var errorTitle = "";
        try {
            errorTitle = jsonData.error;
        } catch (e) {
            errorTitle = "";
        }
        showErrorShowDiv(errorTitle, jsonData.errorDetail);
        return;
    }
    changeHgStatuName(jsonData.baHgbaseinfo.state);
    $("#SBRQ").attr("value", jsonData.baHgbaseinfo.sbrq);
}
function getRequiredElement() {
    return $("[class*='required:true']");
}
function removeRequiredForRequiredsElment(requiredsElments) {
    requiredsElments.each(function () {
        try {
            /* var rules = $(this).rules();
             rules.required = false;
             $(this).rules("remove");*/
            $(this).rules("add", {required: false});
        } catch (e) {

        }
    });
}
function addRequiredForRequiredsElment(requiredsElments) {
    requiredsElments.each(function () {
        try {
            $(this).rules("add", {required: true});
        } catch (e) {

        }
    });
}
